import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'

import routes from './routers/index.js'

import Framework7 from 'framework7/dist/framework7.esm.bundle.js'

import Framework7Vue from 'framework7-vue/dist/framework7-vue.esm.bundle.js'

import Framework7Styles from 'framework7/dist/css/framework7.css'

// Import Icons and App Custom Styles
import './assets/css/icons.css'
import './assets/css/app.css'
// 注入自己的服务到全局实例对象中
import service from './service/index'
// 自定义表单校验
import validator from './utils/validator'
// cordovas设置
import cordovas from './utils/cordovas/index'
// 全局状态管理
import store from './utils/store/index'
// 自定义全局混入
import mymixin from './utils/mixin'
// 全局本地存储管理
import {storageInstall} from './utils/storage'
// 全局过滤器
import filters from './filter/index'
filters()

Vue.use(storageInstall)
mymixin()

Vue.use(Framework7Vue, Framework7, Framework7Styles)
Vue.use(service)
validator(Vue)

Vue.config.productionTip = false

// v-init="{key:item,attr:{proAttr:[]}}
// v-init="{key:item,attr:123}
Vue.directive('init', function (el,binding) {
    let key=binding.value.key;
    let attr=binding.value.attr;
    if(typeof attr=='object'){
        for(let ks in attr){
            key[ks]=attr[ks]
        }
    }else{
        key=attr
    }


});

let myapp = new Vue({
  render: h => h(App),
  framework7: {
    name: 'vue-pass', // App name
    theme: 'ios', // Automatic theme detection
    view: {
      restoreScrollTopOnBack: 'true', // 记住当前位置
      // pushState: 'true', // 是否开启显示路由地址，不打开刷新会进入首页
      mdSwipeBack: 'true' // 安卓手势返回
    },
    // App routes
    routes
  },
  store
}).$mount('#app')

cordovas(myapp)
